package question3;

public class TestsToString extends junit.framework.TestCase
{
    private Memoire m;
    @SuppressWarnings("unused")
	private Variable x,x1;

    public void setUp()
    {
        m  = new Memoire();
        x = new Variable( m, "x", 3 );
        x1 = new Variable( m, "x1", 5 );
    } // setUp()

    public void testElementaire()
    {
        Expression expr;
        expr = new Addition( new Constante(3), new Constante(2) );
        assertEquals( "(3 + 2)",                       expr.toString() );
        expr = new Addition(     expr, new Constante(2) );
        assertEquals( "((3 + 2) + 2)",                 expr.toString() );
        expr = new Addition(     expr, new Factoriel(x1) );
        assertEquals( "{x=3, x1=5}",                   m.toString() );
        assertEquals( "(((3 + 2) + 2) + x1!)",         expr.toString() );
        expr = new Soustraction( expr, new Factoriel(x1) );
        assertEquals( "((((3 + 2) + 2) + x1!) - x1!)", expr.toString() );
    } // testElementaire()
} // TestsToString
